import { defineStore } from 'pinia'
import axios from '@/axios'
export const useCounterStore = defineStore('counter', {
  state: () => ({
    count: '注册',
    user: ''
  }),
  getters: {},
  actions: {
    register(a) {
      if (a == 1) {
        this.count = '注册'
      } else {
        this.count = '确认修改'
      }
    },
    aaa() {
      this.user = ''
      if (localStorage.getItem('username')) {
        axios
          .get('/user', { username: localStorage.getItem('username') })
          .then((d) => {
            this.user = d
          })
          .catch((err) => console.log(err))
      } else {
        this.user = ''
      }
      // console.log(this.user)
    }
  }
})
